package com.CI.ViewAllCourse.Commands
{
	import com.CI.ViewAllCourse.Business.ViewDelegate;
	import com.CI.ViewAllCourse.Control.ViewCourseDirectEvents;
	import com.CI.ViewAllCourse.Control.ViewCourseOnlineEvents;
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	public class ViewCommands implements Command, Responder
	{
		public function ViewCommands()
		{
		}
		
		public function execute(event : CairngormEvent) : void
		{
			var str : String = event.type;
			
			if(str == 'viewCourseDirect')
			{
				var viewCourseDirectEvent : ViewCourseDirectEvents = ViewCourseDirectEvents(event);
				getDelegate.sendObject(viewCourseDirectEvent.courseDirect);
			}
			else
			{
				var viewCourseOnlineEvent : ViewCourseOnlineEvents = ViewCourseOnlineEvents(event);
				getDelegate.sendObject(viewCourseOnlineEvent.courseOnline);
			}
		}
		
		public function onFault(event : *=null) : void
		{
			
		}
		
		public function onResult(event : *=null) : void
		{
			
		}
		
		protected function get getDelegate(): ViewDelegate
		{
			return new ViewDelegate(this);
		}
	}
}